#!/user/bin/env python
# coding=utf-8
"""
@project :
@author  :
#@file   : runCase.py
#@ide    : PyCharm
#@time   :
"""
import os
import pytest


'''
    pytest用例执行文件
'''
def run(case_path):
    # shutil.move(ensure_path_sep("\\test_case\\conftest.py"),root_path())
    # shutil.move(ensure_path_sep("\\test_case\\__init__.py"),root_path())
    # remove_dir(r"D:\zhcx-api-auto\test_case")
    # TestCaseAutomaticGeneration().get_case_automatic()
    # shutil.move(ensure_path_sep("\\conftest.py"),ensure_path_sep("\\test_case"))
    # shutil.move(ensure_path_sep("\\__init__.py"),ensure_path_sep("\\test_case"))
    # now = time.strftime("%Y-%m-%d_%H_%M_%S")
    pytest.main(['-s', case_path, '-W',
                 'ignore:Module already imported:pytest.PytestWarning',
                 '--alluredir', './report/tmp', "--clean-alluredir"])
    # os.system(r"allure generate ./report/tmp -o ./report/html --clean")
    """
           --reruns: 失败重跑次数
           --count: 重复执行次数
           -v: 显示错误位置以及错误的详细信息
           -s: 等价于 pytest --capture=no 可以捕获print函数的输出
           -q: 简化输出信息
           -m: 运行指定标签的测试用例
           -x: 一旦错误，则停止运行
           --maxfail: 设置最大失败次数，当超出这个阈值时，则不会在执行测试用例
            "--reruns=3", "--reruns-delay=2"
           """
    # allure_data = AllureFileClean().get_case_count()
    # notification_mapping = {
    #     NotificationType.DING_TALK.value: DingTalkSendMsg(allure_data).send_ding_notification,
    #     NotificationType.WECHAT.value: WeChatSend(allure_data).send_wechat_notification,
    #     NotificationType.EMAIL.value: SendEmail(allure_data).send_main,
    #     NotificationType.FEI_SHU.value: FeiShuTalkChatBot(allure_data).post
    # }
    #
    # if config.notification_type != NotificationType.DEFAULT.value:
    #     notification_mapping.get(config.notification_type)()
    #
    # if config.excel_report:
    #     ErrorCaseExcel().write_case()


if __name__ == '__main__':
    run(case_path=r"test_case/beta08/cgboss/test_ptexpand.py")
    # run(case_path=r"E:\zhcx-api-auto\test_case\dev\RegionalPickingTask")
    # run(case_path=r"D:\zhcx-api-auto\test_case\dev\ProductLibrary")
    # run(case_path=r"D:\zhcx-api-auto\test_case\Brand_presentation_management")
    # run(case_path=r"D:\zhcx-api-auto\test_case\sales_management\aliexpress\aliexpress_listing\test_batch_create_listing.py")
    # run(case_path=r"D:\zhcx-api-auto\test_case\sales_management\aliexpress\aliexpress_listing\test_single_create_listing.py")